<?php
namespace app\admin\controller\v1;

use app\providers\BaseController;
use hg\apidoc\annotation as Apidoc;
use app\resources\service\NodeService;
use app\resources\validate\NodeValidate;
/**
 * @Apidoc\Title("节点管理")
 * @Apidoc\Group("buss")
 * @Apidoc\Sort(1)
 */
class Nodes extends BaseController 
{
	
	/**
     * @Apidoc\Title("新增节点")
     * @Apidoc\Method("post")
     * @Apidoc\Url("/admin/v1/nodes/add")
     * @Apidoc\Param(ref="app\resources\model\Nodes\getInfoById",withoutField="is_line,loading,id")
     */
	public function add(NodeValidate $validate,NodeService $nodeService)
    {
        $result = $nodeService->createOrUpdate( $validate->goCheck( input('oid') ? 'edit' : 'add') );
        return \Api::ReSucess($result['id']);
	}
	
	/**
     * @Apidoc\Title("重置节点")
     * @Apidoc\Url("/admin/v1/nodes/reset")
     * @Apidoc\Method("post")
     * @Apidoc\Param("id",type="int",require=true,default="",desc="节点id" )
     */
	public function reset(NodeService $nodeService,$id)
    {
        $nodeService->reset( $id );
        return \Api::ReSucess();
	}

}

